package com.mxpio.erp.common.oa.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_OA_OVERTIME_APPLY")
@Schema(description="加班申请单")
public class OaOvertimeApply  extends BaseEntity {

    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "工单编号")
    private String bizNo;

    @Column(name = "EMPLOYEE_NAME_")
    @Schema(description = "员工工号")
    @Dict(dicCode="username", dicEntity = User.class, dicText = "nickname")
    private String employeeId;

    @Column(name = "EMPLOYEE_POST_")
    @Schema(description = "员工职位")
    private String employeePost;

    @Column(name = "DEPT_CODE_")
    @Schema(description = "部门编号")
    @Dict(dicCode="deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String deptCode;

    @Column(name = "OVERTIME_TYPE")
    @Schema(description = "加班时段")
    @Dict(dicCode = "MB_ERP_OA_OVERTIME_TYPE") //10工作日加班，20 周末加班，30 法定节假日加班
    private String overTimeType;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "申请时间")
    @Column(name = "APPLY_TIME_")
    private Date applyTime;

    @Column(name = "OVERTIME_REASON_",columnDefinition = "TEXT")
    @Schema(description = "加班事由")
    private String overTimeReason;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name = "EXPECT_OVERTIME_START_TIME_")
    @Schema(description = "预计加班开始时间")
    private Date expectOverTimeStartTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name = "EXPECT_OVERTIME_END_TIME_")
    @Schema(description = "预计加班结束时间")
    private Date expectOverTimeEndTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name = "REAL_OVERTIME_START_TIME_")
    @Schema(description = "实际加班开始时间")
    private Date realOverTimeStartTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name = "REAL_OVERTIME_END_TIME_")
    @Schema(description = "实际加班结束时间")
    private Date realOverTimeEndTime;

    @Column(name = "WORKING_HOURS_")
    @Schema(description = "加班时长(H)")
    private BigDecimal workingHours;

    @Column(name = "REMARK_")
    @Schema(description = "备注")
    private String remark;

    @Column(name = "ORDER_STATUS_")
    @Schema(description = "工单状态") //10新增 20审核中 30已完成 40已关闭
    @Dict(dicCode = "MB_ERP_OA_INVOICE_ORDER_STATUS")
    private String orderStatus;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;
}
